Skip to content

Fix virtualenv seed cache identity with wheel hashes - #19732

Closed
SeanDougherty wants to merge 2 commits into
fasttrack/3.0from
users/sdougherty/python-virtualenv-content-hash-19710
Closed

SeanDougherty wants to merge 2 commits into
fasttrack/3.0from
users/sdougherty/python-virtualenv-content-hash-19710

Conversation

@SeanDougherty

@SeanDougherty SeanDougherty commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Either/or alternative

Draft alternative to #19721. Choose one approach, not both.

Both PRs independently target fasttrack/3.0 and update
python-virtualenv from 20.36.1-8 to 20.36.1-9. Neither depends on the
other. The original trust-store update, #19710, has already merged.

This PR uses wheel-content hashes instead of #19721's one-time cache
namespace bump.

Change

Include the selected wheel's SHA-256 in the existing seed-image key,
preserving Python-version, installer, and wheel-filename separation.
Different contents select a new image even when the filename, size, and
timestamp are unchanged. Identical contents reuse the image, including
after reinstalling the RPM. No release-specific cache constant is needed.

Deployment and cache cleanup

New environments seeded from the corrected bundled wheels automatically
bypass legacy seed images. No manual cache reset or additional package
update is needed for this cache invalidation.

Legacy files remain on disk to avoid breaking existing symlinked
environments. This does not repair existing environments that still use
affected pip CA bundles; those require a pip update or recreation.
Unused legacy images may be removed after confirming no environments
reference them. Deleting them is not required to protect new environments.

Validation

  • All 12 new regression cases failed on the parent implementation and passed
    with hashing. They cover legacy images, successive same-filename
    replacements, unchanged size/mtime, reuse across locations, rollback,
    unreadable wheels, both pip versions, and copy/symlink seeding.
  • All 16 targeted tests passed, including existing parallel and read-only
    cache tests.
  • Native AMD64 RPM/SRPM build and configured %check passed:
    408 passed, 40 skipped, 2 deselected.
  • An actual AMD64 RPM sequence from release 7 through release 8 to this
    release 9 corrected retained caches. Both pip versions rejected all 14
    incident chains in copy and symlink modes, with fresh and retained caches.
  • RPM reinstall, downgrade, and re-upgrade behavior was checked. Hash images
    were reused when appropriate and existing environments remained unchanged.
  • Measured warm-filesystem-cache hashing cost was approximately 1.3 ms per
    embedded pip wheel on the validation VM, not an end-to-end latency measure.
  • Source signatures, patch applicability, spec guidelines, and RPM digests
    were verified.

ARM64 native validation remains pending.

Key installation images by the selected wheel SHA-256 while retaining installer, Python, and wheel-name separation. Preserve legacy images and reuse identical content without maintaining release-specific cache generations.

Add regressions for legacy images, successive same-name replacements with stable size and mtime, unchanged content across paths, rollback, copy/symlink modes, and unreadable wheels.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Distinguish automatically bypassed seed images from existing environments that still need a pip update or recreation. Explain that legacy files are retained for environments referencing them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SeanDougherty

Copy link
Copy Markdown
Contributor Author

Closing this draft because commit f59907689a01f381c20e92b2461e45e46b1f3968 in #19708 blocks the known compromised eMudhra intermediate keys in CPython's TLS verification, even with stale cached pip CA bundles.

Once the patched runtime is deployed and loaded by restarted processes, cache invalidation is not required for that protection. Certificate verification must remain enabled. The branch is retained for any future work on general same-filename cache consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fasttrack/3.0 PRs Destined for Azure Linux 3.0 Packaging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant